﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using i8i.i7s;
using System.Data.Services;
using System.Data.Services.Client;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;

namespace i8i
{

    public class _out : IHttpHandler
    {
        //public static List<LocationSummary> GetLocationSummary
        //public static List<SummaryGroup> GetActivityGrouped(
        //public static object CalendarSummary
        //public static List<Guest> GetGuestList
        //public static List<ActivityStatus> GetStatusList
        // ar.Summary =  String.Format("{0} - {1} {2}", ar.StartTime , ar.GuestName, summary.Length > 0 ? "[" + summary + "]" : "" );


        public void ProcessRequest(HttpContext context)
        {
            CalendarItem ci = new i7s.CalendarItem();
            string w = ci.ToString();
            
            // Example #1 Get month...

            i7e svc = new i7e(new Uri("http://localhost:11080/i7s.svc/", UriKind.Absolute));                        
            var g = svc.CalendarItems.Where(
                q => q.Create_Date >= DateTime.Today.AddDays(-360)
                    && q.Create_Date <= DateTime.Today.AddDays(-330)).Select(s => s.CalendarItem_ID);
                    ;
           
        }

        private static string SerializeMe(CalendarItem g)
        {
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(CalendarItem));
            MemoryStream ms = new MemoryStream();
            serializer.WriteObject(ms, g);
            string json = Encoding.Default.GetString(ms.ToArray());
            return json;
        }
        public int m_defaultDays_CalendarDisplay = 30;
        public List<CalendarItem> GetLocationSummary(int days)
        {

            return new List<CalendarItem>();
        }

        public List<CalendarItem> GetLocationSummary()
        {

            return GetLocationSummary(m_defaultDays_CalendarDisplay);
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}